package com.MapJiHe;

import java.util.*;

public class MapDemo {
    public static void main(String[] args) {
        //统计投票活动
        String[]address={"A","B","C","D"};
        List<String>data=new ArrayList<>();
        //建立随机数表示同学的选择
        Random r=new Random();
        for (int i = 1; i <=80 ; i++) {
            int index=r.nextInt(4);
            data.add(address[index]);
        }
        System.out.println(data);
        Map<String,Integer>result=new HashMap<>();
        for (String  s : data) {
            if(result.containsKey(s)){
                result.put(s,result.get(s)+1);
            }else{
                result.put(s,1);
            }
        }
        System.out.println(result);
    }
}
